<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML>
<html>
<head>
    <title>Title</title>
    <meta charset="UTF-8">
    <script type="text/javascript" src="<%=request.getContextPath()%>/jquery-1.10.2.min.js"></script>
</head>
<body>
<form action="<%=request.getContextPath()%>/domain?act=list" method="post">
    <input type="hidden" name="pn" id="pageNum">
    域名<input type="text" name="addr" value="${param.addr}">
    ip:<input name="ip" type="text" value="${param.ip}">
    <input type="submit" value="查询">
</form>
<table border="1">
    <tr>
        <td>ID</td>
        <td>域名</td>
        <td>端口</td>
        <td>IP</td>
        <td>状态</td>
        <td>操作</td>
    </tr>
    <c:forEach items="${requestScope.pageInfo.list}" var="d">
        <tr>
            <td>${d.id}</td>
            <td>${d.addr}</td>
            <td>${d.port}</td>
            <td>${d.ip}</td>
            <td>${d.status==1?"启用":"禁用"}</td>
            <td>
                <a href="<%=request.getContextPath()%>/domain?act=info&id=${d.id}">修改</a>
                <a href="<%=request.getContextPath()%>/domain?act=delete&id=${d.id}">删除</a></td>
        </tr>
    </c:forEach>
</table>
<%--条件过多，拼接url麻烦，维护性差；get方式传中文，容易出现乱码问题--%>
<a href="javascript:void(0)" onclick="changePage(1)">首页</a>
<a href="javascript:void(0)" onclick="changePage(${pageInfo.prePage})">上一页</a>
<c:forEach var="n" items="${pageInfo.navigatepageNums}">
    <a href="javascript:void(0)"  onclick="changePage(${n})" style="${n==pageInfo.pageNum?'color:red':''}">${n}</a>
</c:forEach>
<a href="javascript:void(0)"  onclick="changePage(${pageInfo.nextPage})">下一页</a>
<a href="javascript:void(0)"  onclick="changePage(${pageInfo.pages})">末页</a>
共${pageInfo.total}条/${pageInfo.pages}页  当前第${pageInfo.pageNum}页
<script>
function changePage(pn){
    $("#pageNum").val(pn)
    $("form").submit();
}
</script>
</body>
</html>
